<?php
    $turned_up = isset($raw_data['Serviced']) ? $raw_data['Serviced'] : array();
    $not_turned_up = isset($raw_data['Not Serviced']) ? $raw_data['Not Serviced'] : array();
?>
<script type="text/javascript">
    /*    var customers = <?php //echo json_encode($customers_list);?>;
     var reminder_times =  <?php //echo json_encode($reminder_time_list);?>;
     var customers_filter =  <?php //echo json_encode($customers_filter);?>;
     var reminded_filter =  <?php //echo json_encode($reminded_status_filter);?>;
     var serviced_filter =  <?php //echo json_encode($serviced_status_filter);?>;*/
    var pie_data = <?php echo json_encode($pie_data);?>;
    var graph_title = <?php echo json_encode($graph_title);?>;
</script>
<div class="row-fluid">
    <div class="span12">

        <div class="mediamgr_head">
            <ul class="mediamgr_menu">
                <li class="marginleft15 filesearch">
                    <?php echo $this->Form->create('Query', array('id' => 'form-query', 'inputDefaults' => array('label' => false,'div' => false)));?>
                    <?php echo $this->Form->input('customer', array('id' => 'customer', 'class' => '', 'options' => $customers_filter_list, 'div' => false, 'label' => false)); ?>
                    <?php echo $this->Form->input('month', array('id'=>'month', 'class' => '','default'=>$default_month,'options'=>$month_list, 'div' => false, 'label' => false,)); ?>
                    <?php echo $this->Form->input('year', array('id'=>'year', 'class' => 'span2 date-masking validate[required]','default'=>$year,'placeholder'=>'Year (yyyy)','maxlength'=>'4' , 'div' => false, 'label' => false,)); ?>
                    <?php echo $this->Form->input('day', array('id'=>'day', 'class' => 'span2 date-masking validate[required]','default'=>$day,'placeholder'=>'Day (dd)','maxlength'=>'2' , 'div' => false, 'label' => false,)); ?>
                    <button class="btn btn-primary" type="submit" id="query-btn">Re-Query </button>
                    <?php echo $this->Form->end();?>
                </li>
                <!--<li class="right newfilebtn"><a href="#" class="btn btn-primary">Upload New File</a></li>-->
            </ul>
            <span class="clearall"></span>
        </div><!--mediamgr_head-->

    </div>
</div>

<div class="row-fluid">
    <div class="span12">
        <div class="wBlock clearfix">
            <div class="wSpace">
                <div id="pie-content" style="height:370px;"></div>
            </div>
            <script type="text/javascript">
                $(function () {
                    $(document).ready(function() {
                        var options_pie = {
                            chart: {
                                renderTo: 'pie-content',
                                type: 'pie',
                                plotBackgroundColor: null,
                                plotBorderWidth: null,
                                plotShadow: false
                            },
                            title: {
                                text: graph_title
                            },
                            tooltip: {
                                // pointFormat: '{series.name}: <b>{point.y} ltrs {jLib.formatNumber(point.y,'money',1)}%</b>',
                                percentageDecimals: 1,
                                formatter: function(series) {
                                    return ''+this.series.name +':   <b>'+ jLib.formatNumber(this.point.y,'number',0) + ' Count(s)   ' + jLib.formatNumber(this.point.percentage,'number',0) +'%';
                                }
                            },
                            plotOptions: {
                                pie: {
                                    showInLegend: true,
                                    allowPointSelect: true,
                                    cursor: 'pointer',
                                    dataLabels: {
                                        enabled: true,
                                        color: '#000000',
                                        //distance: -30,
                                        formatter: function() {
                                            return '<b>'+ this.point.name  +'  <br /> '+jLib.formatNumber(this.point.y,'number',1) + ' Count(s)   ' + this.percentage.toFixed(1) +' %</b>: ';
                                        }
                                    }
                                }
                            },
                            series: [{
                                type: 'pie',
                                name: 'share',
                                data: pie_data
                            }]
                        };
                        var chart_pie = new Highcharts.Chart(options_pie);
                    });
                });
            </script>
        </div>
        <div class="divider15"></div>
    </div>
</div>

<div class="row-fluid">
    <div class="span12">

        <h4 class="widgettitle">Turned Up List.- <?php echo $table_title ;?>   <button class="btn btn-inverse pull-right print-list" data-id="turned_up" style="margin-bottom: 0px; padding: 0px 10px;">Print List</button></h4>
        <table class="table responsive">
            <thead>
            <tr>
                <th></th>
                <th>Registration Number</th>
                <th>Customer Name</th>
                <th>Reported</th>
            </tr>
            </thead>
            <tbody>
            <?php
                $count = 1;
                foreach($turned_up as $dt){
            ?>
                <tr>
                    <td><?php echo $count; ?></td>
                    <td><?php echo $dt['vehicle_number']; ?></td>
                    <td><?php echo $dt['name']; ?></td>
                    <td><?php echo $dt['turned_up_date']; ?></td>
                </tr>
            <?php
                    $count++;
                }
            ?>
            </tbody>
        </table>

        <div class="divider30"></div>
        <div class="divider30"></div>

        <h4 class="widgettitle">Not Turned Up List.- <?php echo $table_title ;?>  <button class="btn btn-inverse pull-right print-list" data-id="not_turned_up" style="margin-bottom: 0px; padding: 0px 10px;">Print List</button></h4>
        <table class="table responsive">
            <thead>
            <tr>
                <th></th>
                <th>Registration Number</th>
                <th>Customer Name</th>
                <th>Expected</th>
            </tr>
            </thead>
            <tbody>
            <?php
            $count = 1;
            foreach($not_turned_up as $dt){
                ?>
                <tr>
                    <td><?php echo $count; ?></td>
                    <td><?php echo $dt['vehicle_number']; ?></td>
                    <td><?php echo $dt['name']; ?></td>
                    <td><?php echo $dt['expected']; ?></td>
                </tr>
                <?php
                $count++;
            }
            ?>
            </tbody>
        </table>
    </div>

    <form id="print-export-form" method="post" action="<?php echo $this->Html->url(array('controller' => 'ServiceAdviser', 'action' => 'print_export_report_appointments')); ?>" target="PrintExportWindow">
        <input type="hidden" name="data_type" id="data_type" value="" />
        <input type="hidden" name="data_customer" id="data_customer"  value="" />
        <input type="hidden" name="data_month" id="data_month"  value="" />
        <input type="hidden" name="data_year" id="data_year"  value="" />
        <input type="hidden" name="data_day" id="data_day"  value="" />
        <input type="hidden" name="data_status" id="data_status"  value="" />
    </form>
</div>

<!-- URLs -->
<input type="hidden" id="table-url" value="<?php echo $this->Html->url(array('controller' => 'ServiceAdviser', 'action' => 'schedule_appointments/get')); ?>" />
<input type="hidden" id="table-editable-url" value="<?php echo $this->Html->url(array('controller' => 'ServiceAdviser', 'action' => 'schedule_appointments/save')); ?>" />
<input type="hidden" id="delete_url" value="<?php echo $this->Html->url(array('controller' => 'ServiceAdviser', 'action' => 'schedule_appointments/delete')); ?>" />

<!-- Le Script -->

<?php
echo $this->Html->script('scripts/service_advisers/report_appointment.js');
?>
